<template>
    <el-card class="notice-card">
          <template #header>
            <div class="card-header">
              <span>系统公告</span>
            </div>
          </template>
          <el-scrollbar height="200px">
            <ul class="notice-list">
              <li v-for="notice in noticeItems" :key="notice.id" @click="viewDetail(notice.id)">
                <el-icon>
                  <Bell />
                </el-icon>
                {{ notice.title }}
              </li>
            </ul>
          </el-scrollbar>
        </el-card>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router'
  const props = defineProps({
    noticeItems: {
      type: Array,
      required: true
    },
    loading: {
      type: Boolean,
      default: true
    }
  })
  const router = useRouter()
  const viewDetail = (id:number) => {
  //router.push(`/notice/detail/${id}`)
  // 通过路由解析生成完整URL
  const route = router.resolve({
    path: `/notice/detail/${id}`
  })
  
  // 打开新窗口
  window.open(route.href, '_blank')
}
</script>

<style lang="scss" scoped>
@use '@/assets/scss/variables' as *;
 .notice-card {
        border-radius: 12px;
        :deep(.el-card__header) {
          font-size: 16px;
          font-weight: 500;
          color: $text-primary;
        }

        .notice-list {
          list-style: none;
          padding: 0;
          margin: 0;

          li {
            padding: 12px 0;
            transition: all 0.2s ease;
            cursor: pointer;

            &:hover {
              background: #fafafa;
              transform: translateX(5px);
            }

            .el-icon {
              color: $primary-color;
              font-size: 16px;
            }

            &::before {
              content: "·";
              color: $primary-color;
              font-weight: bold;
              margin-right: 8px;
            }
          }
        }
      }
</style>